package com.rentplant.controller;

import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.rentalcollect;
import com.rentplant.Pojo.rentalcollectanduser;
import com.rentplant.service.impl.rentalCollectServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/rentalCollect")
public class rentalCollectController {

    @Autowired
    private rentalCollectServiceImp rentalcollectserserviceimp;

    //查询该租房信息是否收藏
    @RequestMapping("/rentalCollectById")
    public List<rentalcollect> rentalCollectById(@RequestBody JSONObject req){
        try{
            return rentalcollectserserviceimp.rentalCollectById(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //取消租房信息收藏
    @RequestMapping("/delRentalCollect")
    public boolean delRentalCollect(@RequestBody JSONObject req){
        try{
            return rentalcollectserserviceimp.delRentalCollect(req);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    //收藏物品
    @RequestMapping("/addRentalCollect")
    public boolean addRentalCollect(@RequestBody JSONObject req){
        try{
            return rentalcollectserserviceimp.addRentalCollect(req);
        }catch (Exception e){
            throw  new RuntimeException(e);
        }
    }

    //    显示用户收藏的租房信息
    @RequestMapping("/showRentalCollect")
    public List<rentalcollectanduser> showRentalCollect(@RequestBody JSONObject req){
        try{
            return rentalcollectserserviceimp.showRentalCollect(req);
        }catch (Exception e){
            throw  new RuntimeException(e);
        }
    }


}
